<?php

/*

Who's On (whoson.php)

*/

$page_title = "Whos On";
$rank_check = 0;
include "header.inc.php";

$addTo = 0;
$getInactiveMembers = mysql_query("SELECT id,username  FROM members2 WHERE last_hit <= 0");
while ($getInactiveMembers = mysql_fetch_array($getInactiveMembers))
{
	mysql_query("DELETE FROM bank2 WHERE user = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();
	mysql_query("DELETE FROM buds2 WHERE bud_me = '$getInactiveMembers[id]'");	$addTo += mysql_affected_rows();
	mysql_query("DELETE FROM buds2 WHERE bud_you = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();

	$findClubs = mysql_query("SELECT id FROM clubs2 WHERE owner = '$getInactiveMembers[id]'");
	while ($getClubs = mysql_fetch_array($findClubs))
	{
		mysql_query("DELETE FROM club_forums2 WHERE club = '$getClubs[id]'");		$addTo += mysql_affected_rows();
		mysql_query("DELETE FROM club_members2 WHERE club = '$getClubs[id]'");		$addTo += mysql_affected_rows();
		mysql_query("DELETE FROM club_pages2 WHERE club = '$getClubs[id]'");		$addTo += mysql_affected_rows();
	}
	mysql_query("DELETE FROM clubs2 WHERE owner = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();

	mysql_query("DELETE FROM forum_replies2 WHERE author = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();

	$findSubjects = mysql_query("SELECT id FROM forum_subjects2 WHERE author = '$getInactiveMembers[id]'");
	while ($getSubjects = mysql_fetch_array($findSubjects))
	{
		mysql_query("DELETE FROM forum_topics2 WHERE id = '$getSubjects[id]'");
		$addTo += mysql_affected_rows();
	}

	mysql_query("DELETE FROM forum_subjects2 WHERE author = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();

	mysql_query("DELETE FROM mail_messages2 WHERE to_user = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();
	mysql_query("DELETE FROM mail_topics2 WHERE to_user = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();
	mysql_query("DELETE FROM mail_topics2 WHERE from_user = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();
	mysql_query("DELETE FROM members_profiles2 WHERE id = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();
	mysql_query("DELETE FROM messages2 WHERE userid = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();
	mysql_query("DELETE FROM safety_box WHERE owner = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();
	mysql_query("DELETE FROM mail_topics2 WHERE to_user = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();

	$findPets = mysql_query("SELECT id FROM user_pets2 WHERE owner = '$getInactiveMembers[id]'");
	while ($getPets = mysql_fetch_array($findPets))
	{
		mysql_query("DELETE FROM equipped_items WHERE pet_id = '$getPets[id]'");
		$addTo += mysql_affected_rows();
	}
	mysql_query("DELETE FROM user_pets2 WHERE owner = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();
	mysql_query("DELETE FROM usershops2 WHERE owner = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();
	mysql_query("DELETE FROM usershops_items2 WHERE owner = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();
	mysql_query("DELETE FROM usersitems2 WHERE owner = '$getInactiveMembers[id]'");
	$addTo += mysql_affected_rows();
}

mysql_query("DELETE FROM members2 WHERE last_hit <= '0'");
$addTo += mysql_affected_rows();

print "$addTo rows deleted.";

?>